import java.util.*;

/**
 * @author LKQ
 * @date 2022/4/16 20:56
 * @description bitSet
 */
public class Solution {
    public static void main(String[] args) {

    }

    Map<Integer, Integer> map = new HashMap<>();
    int index = 0;
    public int getNumber(TreeNode root, int[][] ops) {
        dfs(root);
        BitSet bit = new BitSet(map.size());
        for (int[] op : ops) {
            int left = op[1], right = op[2];
            bit.set(left, right + 1, op[0] != 0);
        }
        int ans = 0;
        for (int i = 0; i < map.size() ; i++) {
            if (bit.get(i)) {
                ans++;
            }
        }
        return ans;
    }

    private void dfs(TreeNode root) {
        if (root == null) {
            return;
        }
        dfs(root.left);
        map.put(root.val, index++);
        dfs(root.right);
    }
}
